import { SyncResInfoUtil } from "./SyncResInfoUtil";
import { SyncResExecUtil } from "./SyncResExecUtil";
import { FileChangeUtil } from "./FileChangeUtil";
import { Main } from "../Main";
import { PlistCfgGenUtil } from "./PlistCfgGenUtil";
import { NeArt2CocosStudioUtil } from "./NeArt2CocosStudioUtil";
import { Util } from "./Util";
import { FastSyncResInfoUtil } from "./FastSyncResInfoUtil";

/**
 * 快速资源同步工具
 * @author 赵占涛
 */
export class FastSyncResUtil {
    static export(cb: () => void) {
        Util.logTime("开始找变更文件");
        FastSyncResInfoUtil.getChangeList("normal", (needExportList: string[], needDeleteList: string[]) => {
            Util.logTime("结束找变更文件");
            for (let i = 0; i < needExportList.length; i++) {
                console.log("needExportList", i, needExportList[i]);
            }
            for (let i = 0; i < needDeleteList.length; i++) {
                console.log("needDeleteList", i, needDeleteList[i]);
            }
            SyncResExecUtil.exec("normal", needExportList, needDeleteList, () => {
                console.log("syncres exec ok");
                PlistCfgGenUtil.gen(() => {
                    if (needExportList.length != 0 || needDeleteList.length != 0) {
                        cb();
                    } else {
                        cb();
                    }
                });
            });
        });
    }
}